/**
 * @author 
 */
public class RainingNumbers {

	public static void main(String[] args) {
		int x=0, y=0, dx=0, dy=0, score = 0, level = 1, count = 0;
		String text = "";
		//long startTime =System.currentTimeMillis();
		
		Zen.setFont("TimesNewRoman-30");
		dx = 0;
		dy = 2;
		while (Zen.isRunning()) {
			if (text.length() == 0) {
				//x = Zen.getZenWidth() / 2;
				//y = 0;
				x = (int) (Math.random() * 500);
				y = (int) (Math.random() * 500);
				//dx = 0;
				//dy = 2;
				text = "" + (int) (Math.random() * 99);
				//long elapsed = System.currentTimeMillis() - startTime;
				//startTime = System.currentTimeMillis();
				//score += 10000 / elapsed; 
			}
			
			//Zen.setColor(255, 255, 255);
			//Zen.fillRect(0, 0, Zen.getZenWidth(), Zen.getZenHeight());
			Zen.drawImage("mario.jpg",0,0,Zen.getZenWidth(),Zen.getZenHeight());
			
			Zen.setColor(255, 0, 0);
			Zen.drawText(text, x, y);
			
			String user = Zen.getEditText();
			Zen.setEditText("");
			
			x += dx;
			y += dy; 
			
			if (user.equals(text)){
				score = score + 1;
				count = count + 1;
				if (count==5){
					count = 0;
					level = level + 1;
					dy = dy + 5;
						}
					}
		
			
			Zen.drawText("Level: " + level,10,60);
			Zen.drawText("Score: " + score,10,100);
			Zen.drawText("Count: " + count,10,140);
			
			
			for(int i=0;i<user.length();i++) {
				char c = user.charAt(i);
				if(c == text.charAt(0))
					text = text.substring(1);
			}
			
			Zen.sleep(100);

		}
	}

}
